const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}

function getComment() {
  var _this = this;
  //获取评论列表
  wx.request({
    url: 'https://wangjingming.snslearn.com/interface/Comment/getCommentsWithFloor?newer=1&type=5&curId=0&num=5&typeId=42146&token=OWVhOGRjZDI0NWRjM2MwZDhkN2I1NTViYjE0YmUwMjY',
    header: {
      'content-type': 'application/json' // 默认值
    },
    success: function (res) {
      _this.setData({
        commentList: res.data
      })
      console.log(res.data);
    }
  })
}

module.exports = {
  formatTime: formatTime,
  getComment: getComment
}
